//
//  CZStatusBottomView.m
//  XinLang_OC
//
//  Created by WONG on 16/3/14.
//  Copyright © 2016年 cheuhui. All rights reserved.
//

#import "CZStatusBottomView.h"

@interface CZStatusBottomView ()

/**
 *  转发按钮
 */
@property (nonatomic,strong) UIButton *forwardButton;
/**
 *  评论按钮
 */
@property (nonatomic,strong) UIButton *commentButton;
/**
 *  赞按钮
 */
@property (nonatomic,strong) UIButton *likeButton;
/**
 *  分割线1
 */
@property (nonatomic,strong) UIImageView *sImageViewFirst;
/**
 *  分割线2
 */
@property (nonatomic,strong) UIImageView *sImageViewSecond;


@end

@implementation CZStatusBottomView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self prepareUI];
    }
    return self;
}

- (void)prepareUI{
    /*
        添加子控件
     */
    [self addSubview:self.forwardButton];
    [self addSubview:self.commentButton];
    [self addSubview:self.likeButton];
    [self addSubview:self.sImageViewFirst];
    [self addSubview:self.sImageViewSecond];
    
    /*
        添加约束
     */
    // UIView+AutoLayout实现平铺效果
    //[self ff_HorizontalTile:@[self.forwardButton, self.commentButton, self.likeButton] insets:UIEdgeInsetsZero];
    
    // Masonry实现平铺效果
    [self.forwardButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.equalTo(self);
        make.width.equalTo(@(ScreenWidth/3.0));
    }];
    [self.commentButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.width.equalTo(self.forwardButton);
        make.left.equalTo(self.forwardButton.mas_right);
    }];
    [self.likeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.width.equalTo(self.commentButton);
        make.left.equalTo(self.commentButton.mas_right);
    }];

    [self.sImageViewFirst mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.forwardButton.mas_right);
        make.centerY.equalTo(self);
    }];
    [self.sImageViewSecond mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.commentButton.mas_right);
        make.centerY.equalTo(self);
    }];
}



#pragma mark - lazy load

- (UIButton *)forwardButton {
    if (!_forwardButton) {
        _forwardButton = [UIButton new];

        [_forwardButton setImage:[UIImage imageNamed:@"timeline_icon_retweet"] forState:UIControlStateNormal];
        [_forwardButton setTitle:@"转发" forState:UIControlStateNormal];
        [_forwardButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        _forwardButton.titleLabel.font = [UIFont systemFontOfSize:12];
    }
    return _forwardButton;
}
- (UIButton *)commentButton {
    if (!_commentButton) {
        _commentButton = [UIButton new];
        
        [_commentButton setImage:[UIImage imageNamed:@"timeline_icon_comment"] forState:UIControlStateNormal];
        [_commentButton setTitle:@"评论" forState:UIControlStateNormal];
        [_commentButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        _commentButton.titleLabel.font = [UIFont systemFontOfSize:12];
    }
    return _commentButton;
}
- (UIButton *)likeButton {
    if (!_likeButton) {
        _likeButton = [UIButton new];
        
        [_likeButton setImage:[UIImage imageNamed:@"timeline_icon_unlike"] forState:UIControlStateNormal];
        [_likeButton setTitle:@"赞" forState:UIControlStateNormal];
        [_likeButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        _likeButton.titleLabel.font = [UIFont systemFontOfSize:12];
    }
    return _likeButton;
}
- (UIImageView *)sImageViewFirst {
    if (!_sImageViewFirst) {
        _sImageViewFirst = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"timeline_card_bottom_line_highlighted"]];
    }
    return _sImageViewFirst;
}
- (UIImageView *)sImageViewSecond {
    if (!_sImageViewSecond) {
        _sImageViewSecond = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"timeline_card_bottom_line_highlighted"]];
    }
    return _sImageViewSecond;
}



@end
















